package com.yanfan.ccapicode.handler.report.xiaomi;

import com.alibaba.fastjson2.JSONObject;
import com.yanfan.ccapicode.bean.enums.ReportTypeEnum;
import com.yanfan.ccapicode.enums.ThirdPartyCloudEnum;
import com.yanfan.ccapicode.handler.factory.DeviceReportHandlerFactory;
import com.yanfan.ccapicode.service.ThirdPartyConfigService;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/** **/
@Service
public class XiaomiDeviceFunctionReportHandler extends AbstractXiaomiDeviceMessageReportHandler {

    public XiaomiDeviceFunctionReportHandler(DeviceReportHandlerFactory factory, RestTemplate restTemplate, ThirdPartyConfigService thirdPartyConfigService) {
        super(factory, restTemplate, thirdPartyConfigService);
    }

    @Override
    protected String getDeviceId(String message) {
        return JSONObject.parseObject(message).getString("deviceId");
    }

    @Override
    protected String getTopic() {
        return "device-properties-changed";
    }

    @Override
    public ThirdPartyCloudEnum getCloud() {
        return ThirdPartyCloudEnum.XIAOMI;
    }

    @Override
    public ReportTypeEnum type() {
        return ReportTypeEnum.FUNCTION;
    }
}
